package com.ruoyi.biz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.IhReport;
import com.ruoyi.biz.service.IIhReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 举报信息表Controller
 * 
 * @author ruoyi
 * @date 2024-08-15
 */
@RestController
@RequestMapping("/biz/reportrInformation")
public class IhReportController extends BaseController
{
    @Autowired
    private IIhReportService ihReportService;

    /**
     * 查询举报信息表列表
     */
    @PreAuthorize("@ss.hasPermi('biz:reportrInformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(IhReport ihReport)
    {
        startPage();
        List<IhReport> list = ihReportService.selectIhReportList(ihReport);
        return getDataTable(list);
    }

    /**
     * 导出举报信息表列表
     */
    @PreAuthorize("@ss.hasPermi('biz:reportrInformation:export')")
    @Log(title = "举报信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IhReport ihReport)
    {
        List<IhReport> list = ihReportService.selectIhReportList(ihReport);
        ExcelUtil<IhReport> util = new ExcelUtil<IhReport>(IhReport.class);
        util.exportExcel(response, list, "举报信息表数据");
    }

    /**
     * 获取举报信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:reportrInformation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ihReportService.selectIhReportById(id));
    }

    /**
     * 新增举报信息表
     */
    @PreAuthorize("@ss.hasPermi('biz:reportrInformation:add')")
    @Log(title = "举报信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IhReport ihReport)
    {
//        System.out.println("哈哈哈"+ihReport.toString());
        return toAjax(ihReportService.insertIhReport(ihReport));
    }

    /**
     * 修改举报信息表
     */
    @PreAuthorize("@ss.hasPermi('biz:reportrInformation:edit')")
    @Log(title = "举报信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IhReport ihReport)
    {
        return toAjax(ihReportService.updateIhReport(ihReport));
    }

    /**
     * 删除举报信息表
     */
    @PreAuthorize("@ss.hasPermi('biz:reportrInformation:remove')")
    @Log(title = "举报信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ihReportService.deleteIhReportByIds(ids));
    }
}
